package com.ruoyi.project.syl_DZ.D.OutpatientPatient.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.syl_DZ.D.OutpatientPatient.domain.SylDeptCopy1 ;
import com.ruoyi.project.syl_DZ.D.OutpatientPatient.service.ISylDeptCopy1Service ;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 科室Controller
 *
 * @author ruoyi
 * @date 2021-07-15
 */
@RestController
@RequestMapping("/system/copy1")
public class SylDeptCopy1Controller extends BaseController
{
    @Autowired
    private ISylDeptCopy1Service sylDeptCopy1Service;

    /**
     * 查询科室列表
     */
    @PreAuthorize("@ss.hasPermi('DZ:OutpatientPatient:list')")
    @GetMapping("/list")
    public TableDataInfo list(SylDeptCopy1 sylDeptCopy1)
    {
        startPage();
        List<SylDeptCopy1> list = sylDeptCopy1Service.selectSylDeptCopy1List(sylDeptCopy1);
        return getDataTable(list);
    }

    /**
     * 导出科室列表
     */
    @PreAuthorize("@ss.hasPermi('system:copy1:export')")
    @Log(title = "科室", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SylDeptCopy1 sylDeptCopy1)
    {
        List<SylDeptCopy1> list = sylDeptCopy1Service.selectSylDeptCopy1List(sylDeptCopy1);
        ExcelUtil<SylDeptCopy1> util = new ExcelUtil<SylDeptCopy1>(SylDeptCopy1.class);
        return util.exportExcel(list, "copy1");
    }

    /**
     * 获取科室详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:copy1:query')")
    @GetMapping(value = "/{deptId}")
    public AjaxResult getInfo(@PathVariable("deptId") Long deptId)
    {
        return AjaxResult.success(sylDeptCopy1Service.selectSylDeptCopy1ById(deptId));
    }

    /**
     * 新增科室
     */
    @PreAuthorize("@ss.hasPermi('system:copy1:add')")
    @Log(title = "科室", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SylDeptCopy1 sylDeptCopy1)
    {
        return toAjax(sylDeptCopy1Service.insertSylDeptCopy1(sylDeptCopy1));
    }

    /**
     * 修改科室
     */
    @PreAuthorize("@ss.hasPermi('system:copy1:edit')")
    @Log(title = "科室", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SylDeptCopy1 sylDeptCopy1)
    {
        return toAjax(sylDeptCopy1Service.updateSylDeptCopy1(sylDeptCopy1));
    }

    /**
     * 删除科室
     */
    @PreAuthorize("@ss.hasPermi('system:copy1:remove')")
    @Log(title = "科室", businessType = BusinessType.DELETE)
	@DeleteMapping("/{deptIds}")
    public AjaxResult remove(@PathVariable Long[] deptIds)
    {
        return toAjax(sylDeptCopy1Service.deleteSylDeptCopy1ByIds(deptIds));
    }
}
